<?php

//<editor-fold defaultstate="collapsed" desc="License & Copyright">
/*
 * @license
 */

/**
 *
 * @author Jevgeni Geimanen (jevgeni.geimanen@gmail.com)
 */
//</editor-fold>
class SCNavigator extends Component {

    const EVENT_CHANGE = 'CHANGE';

    private $_CurrentItem = null;

    public function getCurrentItem() {
        if ($this->_CurrentItem === null) {
            if ($this->_NavigationItems != null && ($c = Site::getInstance()->getFdatValue('c')) != null && isset($this->_NavigationItems[$c])) {
                $this->_CurrentItem = $c;
            }
        }
        return $this->_CurrentItem;
    }

    //<editor-fold defaultstate="collapsed" desc="Overrides">
    public function DispatchEvents() {
        if ($this->getCurrentItem() != null)
            $this->fireEvent(Navigator::EVENT_CHANGE);
        return parent::DispatchEvents();
    }

    //</editor-fold>    
    //<editor-fold defaultstate="collapsed" desc="NavigationItems">
    /**
     * @var array
     */
    private $_NavigationItems = null;

    /**
     *
     * @return array
     */
    public function getNavigationItems() {
        return $this->_NavigationItems;
    }

    /**
     *
     * @param array $items
     * @return NavigationItems 
     */
    public function setNavigationItems($items) {
        $this->_NavigationItems = $items;
        return $this;
    }

    //</editor-fold>
}

?>
